package medicalSystem;

import java.util.ArrayList;

public class MedicalServer {
	
	private static MedicalServer instance = null;
	
	ArrayList<Patient> patients;
	ArrayList<File> files;
	ArrayList<Doctor> doctors;
	ArrayList<Report> reports;


	public void deleteFile(String doctorName, String fileName){
		
	}
	
	private MedicalServer() {
		super();
		this.patients = new ArrayList<Patient>();
		this.doctors = new ArrayList<Doctor>();
		this.files = new ArrayList<File>();
		this.reports = new ArrayList<Report>();

	}

	public ArrayList<Patient> getPatients() {
		return patients;
	}

	public void setPatients(ArrayList<Patient> patients) {
		this.patients = patients;
	}
	
	public void addPatient(Patient patient) {
		this.patients.add(patient);
	}

	public void addFile(File file) {
		this.files.add(file);
	}
	
	public void addReport(Report report) {
		this.reports.add(report);
	}
	
	public void addDoctor(Doctor doctor) {
		this.doctors.add(doctor);
	}
	
	public ArrayList<File> getFiles() {
		return files;
	}

	public void setFiles(ArrayList<File> files) {
		this.files = files;
	}

	public ArrayList<Doctor> getDoctors() {
		return doctors;
	}

	public void setDoctors(ArrayList<Doctor> doctors) {
		this.doctors = doctors;
	}

	public ArrayList<Report> getReports() {
		return reports;
	}

	public void setReports(ArrayList<Report> reports) {
		this.reports = reports;
	}

	public String viewFile(String doctorName, String fileName){
		return "file_content";
	}
	
	public File createFile(String fileName, String fileType, String patientName){
		File f = new File(fileName, fileType, patientName);
		files.add(f);
		return f;
	}
	
	
	public Doctor createDoctor(String doctorName){
		Doctor d = new Doctor(doctorName);
		doctors.add(d);
		return d;
	}
	
	public Patient createPatient(String patientName){
		Patient p = new Patient(patientName);
		patients.add(p);
		return p;
	}
	
	public Report createReport(String fileName, String fileType, String patientName){
		Report p = new Report( fileName,  fileType,  patientName);
		reports.add(p);
		return p;
	}
	
	public void assign(String doctor, String patientName){
		for(Doctor d : doctors){
			if(d.getName().endsWith(doctor)){
				d.addPatient(patientName);
			}
		}
	}

	static public MedicalServer getInstance() {
		if(instance==null){
			instance= new MedicalServer();
			return instance;
		}
		else return instance;
	}
	
	
}
